package com.nari.ysphd.adapter;

import java.util.ArrayList;
import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

public class ContentPageAdapter extends PagerAdapter {
	private List<View> pageViews;
	public ContentPageAdapter(ArrayList<View> pageViews) {
		this.pageViews = pageViews;
	}

	//获取当前窗体界面数
	@Override
	public int getCount() {
		 return pageViews.size();
	}

	// 判断是否由对象生成界面
	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}
	
	 //销毁position位置的界面
    @Override
    public void destroyItem(View v, int position, Object arg2) {
        ((ViewPager) v).removeView(pageViews.get(position));

    }
    
    //初始化position位置的界面
    @Override
    public Object instantiateItem(View v, int position) {
        ((ViewPager) v).addView(pageViews.get(position));
        return pageViews.get(position);
    }

}
